package business.impl;

import java.util.List;

import model.TPractice;
import model.Tarticle;
import model.Varticle;
import model.Vnews;
import business.basic.iHibBaseDAO;
import business.basic.iHibBaseDAOImpl;
import business.dao.ArticleDao;

public class ArticleDaoImpl implements ArticleDao {
	

	iHibBaseDAO bdao = null;
	public void setBdao (iHibBaseDAO bdao){
		this.bdao=bdao;
		
	}

	@Override
	public Tarticle getarticleById(int id) {
		Tarticle title = (Tarticle) bdao.findById(Tarticle.class,id);
		return title;
	}

	@Override
	public int addarticle(Tarticle model) {
		Object obj = bdao.insert(model);
		if (obj == null) {
			return 0;
		}
		return 1;
	}

	@Override
	public boolean uparticle(Tarticle model) {
		return bdao.update(model);
	}

	@Override
	public boolean delarticle(int id) {
		return bdao.delete(Tarticle.class, id);
	}

	@Override
	public List<Tarticle> getarticlebystuid(int stuid) {
		String sql = " from Tarticle where stuinfoid =   ?";
		Object[] para = {stuid};
		List<Tarticle> modl = bdao.select(sql, para);
		return modl;
	}

	@Override
	public List<Varticle> getarticles() {
		String sql = " from Varticle";
		
		List<Varticle> modl = bdao.select(sql);
		return modl;
	}

	@Override
	public Varticle getarticleby(int id) {
		String sql = " from Varticle  where artsid= ?  ";
		Object[] para = {id};
		Varticle modl = (Varticle) bdao.selectby(sql, para);
		return modl;
	}

	@Override
	public List<Varticle> getarlist(int id) {
		String sql = " from Varticle where stuinfoid =   ?";
		Object[] para = {id};
		List<Varticle> modl = bdao.select(sql,para);
		return modl;
	}

}
